package com.example.langchain4j01.config;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration(proxyBeanMethods = false)
public class AiModel {

    @Autowired
    private Environment env;

    @Bean
    public ChatLanguageModel chatLanguageModel() {
        return OpenAiChatModel.builder()
                .apiKey(env.getProperty("llm.chat.apiKey"))
                .modelName(env.getProperty("llm.chat.modelName"))
                .baseUrl(env.getProperty("llm.chat.baseUrl"))
                .build();
    }

}
